package test.serverframe.armc.server.manager.dao.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

import test.serverframe.armc.server.manager.controller.vo.InvokeRecordPage;
import test.serverframe.armc.server.manager.domain.InvokeRecord;
import test.serverframe.armc.server.manager.domain.params.InvokePage;

public interface InvokeRecordMapper {
    @Delete({
        "delete from tb_ssgp_invoke_record",
        "where record_id = #{recordId,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String recordId);

    @Insert({
        "insert into tb_ssgp_invoke_record (record_id, task_invoke_id, ",
        "start_time, end_time, task_total, task_success_total, status, node_arr)",
        "values (#{recordId,jdbcType=VARCHAR}, #{taskInvokeId,jdbcType=VARCHAR}, ",
        "#{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, ",
        "#{taskTotal,jdbcType=VARCHAR}, #{taskSuccessTotal,jdbcType=VARCHAR}, ",
        "#{status,jdbcType=BIT}, #{nodeArr,jdbcType=VARCHAR})"
    })
    int insert(InvokeRecord record);

    @InsertProvider(type=InvokeRecordSqlProvider.class, method="insertSelective")
    int insertSelective(InvokeRecord record);

    @Select({
        "select",
        "record_id, task_invoke_id, start_time, end_time, task_total, task_success_total, ",
        "status, node_arr",
        "from tb_ssgp_invoke_record",
        "where record_id = #{recordId,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="record_id", property="recordId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="task_invoke_id", property="taskInvokeId", jdbcType=JdbcType.VARCHAR),
        @Result(column="start_time", property="startTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="end_time", property="endTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="task_total", property="taskTotal", jdbcType=JdbcType.VARCHAR),
        @Result(column="task_success_total", property="taskSuccessTotal", jdbcType=JdbcType.VARCHAR),
        @Result(column="status", property="status", jdbcType=JdbcType.BIT),
        @Result(column="node_arr", property="nodeArr", jdbcType=JdbcType.VARCHAR),
    })
    InvokeRecord selectByPrimaryKey(String recordId);

    @UpdateProvider(type=InvokeRecordSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(InvokeRecord record);

    @Update({
        "update tb_ssgp_invoke_record",
        "set task_invoke_id = #{taskInvokeId,jdbcType=VARCHAR},",
          "start_time = #{startTime,jdbcType=TIMESTAMP},",
          "end_time = #{endTime,jdbcType=TIMESTAMP},",
          "task_total = #{taskTotal,jdbcType=VARCHAR},",
          "task_success_total = #{taskSuccessTotal,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=BIT}",
          "node_arr = #{nodeArr,jdbcType=VARCHAR},",
        "where record_id = #{recordId,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(InvokeRecord record);
    
    @SelectProvider(type = InvokeRecordSqlProvider.class, method = "selectByPage")
    @Results({
        @Result(column="record_id", property="recordId", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="task_invoke_id", property="taskInvokeId", jdbcType=JdbcType.VARCHAR),
        @Result(column="start_time", property="startTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="status", property="status", jdbcType=JdbcType.BIT),
        @Result(column="node_arr", property="nodeArr", jdbcType=JdbcType.VARCHAR),
    })
    List<InvokeRecordPage> selectByPage(InvokePage invokePage);

    
}